package org.prem.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class Main13 {

	public static void main(String args[]){
		StudentCertification13 studentCertification1 = new StudentCertification13(); 
		studentCertification1.setCertification_name("Core JAVA certification Exam");
		
		StudentCertification13 studentCertification2 = new StudentCertification13(); 
		studentCertification2.setCertification_name("Oracle DB certification Exam");
		
		Student13 student13_1 = new Student13();
		student13_1.setStudent_name("Prem");
		student13_1.getStudentCertification13().add(studentCertification1);
		
		Student13 student13_2 = new Student13();
		student13_2.setStudent_name("Kumar");
		student13_2.getStudentCertification13().add(studentCertification2);
				
		SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
		Session session = sessionFactory.openSession();
		session.beginTransaction();
		
		session.save(student13_1);
		session.save(student13_2);
		
		session.getTransaction().commit();
		session.close();
		sessionFactory.close();
		
	}

}
